/**
 * Created by necis.zhang on 2016/08/02.
 */
var infoShow = {
    categoriesShow: false,
    categoriesIndex: 0,
    seriesShow: false,
    seriesIndex: 0,
    sizeShow: false,
    sizeIndex: 0,
    queryShow: false,
    query: false,
    SeriesId: 0,
    SizeId: 0
};


$(function () {
    SelectCategories();
    $('#categories').on('click', function (event) {
        event.stopPropagation();
        infoShow.seriesShow = false;
        infoShow.sizeShow = false;
        $('#Series').find('ol').hide();
        $('#Size').find('ol').hide();
        if (infoShow.categoriesShow == false) {
            $(this).find('ol').show();
            infoShow.categoriesShow = true;
        } else {
            $(this).find('ol').hide();
            infoShow.categoriesShow = false;
        }
    });
    $('#Series').on('click', function (event) {
        event.stopPropagation();
        infoShow.categoriesShow = false;
        infoShow.sizeShow = false;
        $('#categories').find('ol').hide();
        $('#Size').find('ol').hide();

        var isDisabled = $(this).hasClass('disabled');
        if (!isDisabled) {
            if (infoShow.seriesShow == false) {
                $(this).find('ol').show();
                infoShow.seriesShow = true;
            } else {
                $(this).find('ol').hide();
                infoShow.seriesShow = false;
            }
        }
    });
    $('#Size').on('click', function (event) {
        infoShow.categoriesShow = false;
        infoShow.seriesShow = false;
        $('#series').find('ol').hide();
        $('#categories').find('ol').hide();

        var isDisabled = $(this).hasClass('disabled');
        if (!isDisabled) {
            if (infoShow.sizeShow == false) {
                $(this).find('ol').show();
                infoShow.sizeShow = true;
            } else {
                $(this).find('ol').hide();
                infoShow.sizeShow = false;
            }
        }
        event.stopPropagation();
    });

    $('#selectRestart').on('click',function () {
        $('#acfSubmit').attr({disabled: "disabled"});
        $('#categories .confirmed-value').text('');
        $('#Series').addClass('disabled');
        $('#Series .confirmed-value').text('');
        $('#Size').addClass('disabled');
        $('#Size .confirmed-value').text('');

        $('.acf-tool').show();
        $('.acf-tool-select').hide();
        $(".acf-tool_information_part1").html('').hide();
        $(".acf-tool_information_part2").html('').hide();
        $(".acf-tool_information_part3").html('').hide();
        $(".acf-tool_information_part3_2").html('').hide();
        $(".acf-tool_information_part4").html('').hide();
        $(".acf-tool_information_part4_2").html('').hide();
        $(".acf-tool_information_part5").html('').hide();
    });
    $('#acfSubmit').on('click', function () {
        $('.acf-tool').hide();
        $('.acf-tool-select').show();
        getProductInfo();
    });
});
/**** 选择选择您产品的类别 ****/
function SelectCategories() {
    var sHtml = new Array();
    var infoList = data_acftool.data.Categories;
    for (var i = 0; i < infoList.length; i++) {
        var name = infoList[i].CategoriesName;
        sHtml.push("<li index=");
        sHtml.push(i);
        sHtml.push(">");
        sHtml.push(name);
        sHtml.push("</li>");
    }
    $("#categories ol").html(sHtml.join(""));
    $("#categories ol li").on('click', function (event) {
        infoShow.categoriesIndex = $(this).attr('index');
        var confirmValue = $(this).text();
        $('#categories .confirmed-value').text(confirmValue);
        $('#Series').removeClass('disabled');
        $('#Series .confirmed-value').text('');
        $('#Size').addClass('disabled');
        $('#Size .confirmed-value').text('');
        SelectSeries();
        $('#acfSubmit').attr({disabled: "disabled"});
    });

}
/*******选择您产品的系列*******/
function SelectSeries() {
    var sHtml = new Array();
    var infoList = data_acftool.data.Categories[infoShow.categoriesIndex].Series;
    for (var i = 0; i < infoList.length; i++) {
        var name = infoList[i].SeriesName;
        sHtml.push("<li index=");
        sHtml.push(i);
        sHtml.push(">");
        sHtml.push(name);
        sHtml.push("</li>");
    }
    $("#Series ol").html(sHtml.join(""));
    $("#Series ol li").on('click', function (event) {
        infoShow.seriesIndex = $(this).attr('index');
        var confirmValue = $(this).text();
        $('#Series .confirmed-value').text(confirmValue);
        $('#Size').removeClass('disabled');
        $('#Size .confirmed-value').text('');
        SelectSize();
        $('#acfSubmit').attr({disabled: "disabled"});
    });
}
/*******选择您产品的包装大小*******/
function SelectSize() {
    var sHtml = new Array();
    var infoList = data_acftool.data.Categories[infoShow.categoriesIndex].Series[infoShow.seriesIndex].Size;
    for (var i = 0; i < infoList.length; i++) {
        var name = infoList[i].SizeName;
        sHtml.push("<li index=");
        sHtml.push(i);
        sHtml.push(">");
        sHtml.push(name);
        sHtml.push("</li>");
    }
    $("#Size ol").html(sHtml.join(""));
    $("#Size ol li").on('click', function (event) {
        infoShow.sizeIndex = $(this).attr('index');
        var confirmValue = $(this).text();
        $('#Size .confirmed-value').text(confirmValue);
        $('#acfSubmit').removeAttr('disabled');
    });
}
/****根据产品型号显示产品信息*****/
function getProductInfo() {
    var sHtml_Part1 = new Array(),
        sHtml_Part2 = new Array(),
        sHtml_Part3 = new Array(),
        sHtml_Part3_2 = new Array(),
        sHtml_Part4 = new Array(),
        sHtml_Part4_2 = new Array(),
        sHtml_Part5 = new Array(),
        sHtml_Part6 = new Array();
    var infoList = data_acftool.data.Categories[infoShow.categoriesIndex].Series[infoShow.seriesIndex].Size[infoShow.sizeIndex].product;
    // console.log(infoList);
    var productWord = infoList.productWord,
        productName = infoList.productName,
        productSize = infoList.productSize,
        productImg = infoList.productImg,
        productLink = infoList.productLink,
        productMore = infoList.productMore,
        step01Img = infoList.step01Img,
        step01Word1 = infoList.step01Word1,
        step01Word2 = infoList.step01Word2,
        queryMode = infoList.queryMode,
        queryMobileImg = infoList.queryMobileImg,
        queryModeSteps = infoList.queryModeSteps,
        queryMode3= infoList.queryMode3,
        query3ModeSteps= infoList.query3ModeSteps,
        checkFunctionTitle = infoList.checkFunctionTitle,
        checkFunctionSteps = infoList.checkFunctionSteps,
        checkFunctionTitle2 = infoList.checkFunctionTitle2,
        checkFunctionImg=infoList.checkFunctionImg,
        checkFunctionSteps2 = infoList.checkFunctionSteps2,
        steps = infoList.steps,
        bottom = infoList.bottom;

    <!--产品系列-->
    sHtml_Part1.push("<div class='acf-tool_information_part1_left'><img alt='' src=");
    sHtml_Part1.push(productImg);
    sHtml_Part1.push("></div>");
    sHtml_Part1.push("<div class='acf-tool_information_part1_right'><p class='acf-tool_information_part1_right_title1'>");
    sHtml_Part1.push(productWord);
    sHtml_Part1.push("</p>");
    sHtml_Part1.push("<p class='acf-tool_information_part1_right_title2'>");
    sHtml_Part1.push(productName);
    sHtml_Part1.push("</p>");
    sHtml_Part1.push("<p class='acf-tool_information_part1_right_title3'>");
    sHtml_Part1.push(productSize);
    sHtml_Part1.push("</p>");
    sHtml_Part1.push("<p class='acf-tool_information_part1_right_link'><a target='_blank' href=");
    sHtml_Part1.push(productLink);
    sHtml_Part1.push(">");
    sHtml_Part1.push(productMore);
    sHtml_Part1.push("</a></p></div>");
    $(".acf-tool_information_part1").html(sHtml_Part1.join("")).show();

    <!--二维码验证-->
    if(step01Img){
        sHtml_Part2.push("<div class='acf-tool_information_part2_left common_left'><img alt='' src=");
        sHtml_Part2.push(step01Img);
        sHtml_Part2.push("></div>");
        sHtml_Part2.push("<div class='acf-tool_information_part2_right common_right'><p class='acf-tool_information_part2_right_title1'>");
        sHtml_Part2.push(step01Word1);
        sHtml_Part2.push("</p><p class='acf-tool_information_part2_right_title2'>");
        sHtml_Part2.push(step01Word2);
        sHtml_Part2.push("</p></div></div>");
        $(".acf-tool_information_part2").html(sHtml_Part2.join("")).show();   
    }
    
    <!--四种查询-->
    if(queryMode){
        sHtml_Part3.push("<div class='acf-tool_information_part3_left common_left'><img alt='' src=");
        sHtml_Part3.push(queryMobileImg);
        sHtml_Part3.push("></div>");
        sHtml_Part3.push("<div class='acf-tool_information_part3_right common_right'><p class='acf-tool_information_part3_right_title1'>");
        sHtml_Part3.push(queryMode);
        sHtml_Part3.push("</p>");
        for (var i = 0; i < queryModeSteps.length; i++) {
            sHtml_Part3.push("<p class='acf-tool_information_part3_right_title2'><span class='acf-tool_information_part3_info part3_info_img'><img alt='' src=");
            sHtml_Part3.push(queryModeSteps[i].querySmallImg);
            sHtml_Part3.push("></span><span class='acf-tool_information_part3_info'>");
            sHtml_Part3.push(queryModeSteps[i].querySmallInfo);
            sHtml_Part3.push("</span></p>");
        }
        sHtml_Part3.push("</div>");
        $(".acf-tool_information_part3").html(sHtml_Part3.join("")).show();
    }

    <!--三种查询-->
    if(queryMode3){
        sHtml_Part3_2.push("<div class='acf-tool_information_part3_2_right common_right'><p class='acf-tool_information_part3_2_right_title1'>");
        sHtml_Part3_2.push(queryMode3);
        for(var i=0; i<query3ModeSteps.length;i++){
            sHtml_Part3_2.push("</p><p class='acf-tool_information_part3_2_right_title2'><span class='acf-tool_information_part3_2_info part3_info_img'><img alt='' src=");
            sHtml_Part3_2.push(query3ModeSteps[i].querySmallImg);
            sHtml_Part3_2.push("></span><span class='acf-tool_information_part3_2_info'>");
            sHtml_Part3_2.push(query3ModeSteps[i].querySmallInfo);
            sHtml_Part3_2.push("</span></p>");
        }
        sHtml_Part3_2.push("</div>");
        $(".acf-tool_information_part3_2").html(sHtml_Part3_2.join("")).show();
    }


    <!--检验方法-->
    if(checkFunctionTitle){
        sHtml_Part4.push("<div class='acf-tool_information_part4_right common_right'> <p class='acf-tool_information_part4_right_title1'>");
        sHtml_Part4.push(checkFunctionTitle);
        for(var i=0;i <checkFunctionSteps.length;i++){
            sHtml_Part4.push("<p class='acf-tool_information_part4_right_title2'><span class='part4_info_img'><img alt='' src=");
            sHtml_Part4.push(checkFunctionSteps[i].checkFunctionStepImg);
            sHtml_Part4.push("></span><span class='part4_info_word'>");
            sHtml_Part4.push(checkFunctionSteps[i].checkFunctionStepWord);
            sHtml_Part4.push("</span></p>");
        }
        sHtml_Part4.push("</div>");
        $(".acf-tool_information_part4").html(sHtml_Part4.join("")).show();
    }

    <!--三种查询检验方法-->
    if(checkFunctionSteps2){
        sHtml_Part4_2.push("<div class='acf-tool_information_part4_2_left common_left'><img alt='' src=");
        sHtml_Part4_2.push(checkFunctionImg);
        sHtml_Part4_2.push("></div><div class='acf-tool_information_part4_2_right common_right'><p class='acf-tool_information_part4_2_right_title1'>");
        sHtml_Part4_2.push(checkFunctionTitle2);
        sHtml_Part4_2.push("</p>");
        for(var i=0;i<checkFunctionSteps2.length;i++){
            sHtml_Part4_2.push("<p class='acf-tool_information_part4_2_right_title2'><span class='acf-tool_information_part4_2_info part4_2_info_img'><img alt='' src=");
            sHtml_Part4_2.push(checkFunctionSteps2[i].checkFunctionStepImg);
            sHtml_Part4_2.push("></span><span class='acf-tool_information_part4_2_info'>");
            sHtml_Part4_2.push(checkFunctionSteps2[i].checkFunctionStepWord);
            sHtml_Part4_2.push("</span></p>");
        }
        sHtml_Part4_2.push("</div>");
        $(".acf-tool_information_part4_2").html(sHtml_Part4_2.join("")).show();
    }
    
    <!--检验步骤-->
    if(steps){
        for(var i=0;i<steps.length;i++){
            sHtml_Part5.push("<div class='filter-nav step_common'><div class='acf-tool_information_step common_part'><div class='acf-tool_information_step_left common_left'><img alt='' src=");
            sHtml_Part5.push(steps[i].stepImg);
            sHtml_Part5.push("></div><div class='acf-tool_information_step_right common_right'><p class='acf-tool_information_step_right_title1'>");
            sHtml_Part5.push(steps[i].stepTitle1);
            sHtml_Part5.push("</p><p class='acf-tool_information_step_right_title2'>");
            sHtml_Part5.push(steps[i].stepTitle2);
            sHtml_Part5.push("</p></div></div></div>");
        }
        $(".acf-tool_information_part5").html(sHtml_Part5.join("")).show();
    }

    <!--底部信息-->
    for(var i=0; i<bottom.length;i++){
        sHtml_Part6.push("<li>");
        sHtml_Part6.push(bottom[i].bottomInfo);
        sHtml_Part6.push("</li>")
    }
    $(".acf-tool_info_bottom").html(sHtml_Part6.join(""));

    
}

